#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 22;
const int S = 1 << 20;
const int mod = 998244353;

int U,s[S],n,a[N];
ll f[S],g[S],ans;

template <typename T>
void add(T &x,T y){x = (x + y) % mod;}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 0;i < n;i++) a[i] = in,s[1 << i] = a[i];
	U = 1 << n;
	for(int i = 1;i < U;i++) s[i] = s[i ^ (i & (-i))] + s[i & (-i)];
	for(int i = 0;i < n;i++) f[1 << i] = 1; g[0] = 1;
	for(int st = 1;st < U;st++)
		if(s[st] >= 0){
			for(int i = 0;i < n;i++)
				if(!(st >> i & 1)) add(f[st | 1 << i],f[st]);
		}else{
			for(int i = 0;i < n;i++)
				if(st >> i & 1)
					add(g[st],g[st ^ 1 << i]);
		}
	for(int st = 1;st < U;st++) add(ans,s[st] % mod * f[st] % mod * g[(U - 1) ^ st] % mod);
	ans = (ans % mod + mod) % mod;
	printf("%lld\n",ans);
	return 0;
}
